package shopping.management;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import shopping.commons.BaseAction;
import shopping.model.LoginInfo;
import shopping.model.Role;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: mazhao
 * Date: 2010/11/17
 * Time: 0:43:55
 * To change this template use File | Settings | File Templates.
 */
public class UserAction extends BaseAction {

    // ===================================
    // data for communication
    // ===================================

    private List<LoginInfo> users;

    public List<LoginInfo> getUsers() {
        return users;
    }

    public void setUsers(List<LoginInfo> users) {
        this.users = users;
    }

    private List<Role> roles;

    public List<Role> getRoles() {
        return roles;
    }

    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }

    /**
     * list user action
     * @return user list page
     */

    @Action(
            value = "/management/userlist",
            results = {
                    @Result( name = "success", location = "/WEB-INF/content/management/user.jsp")
            }
    )
    public String listUser() {
        log.debug("enter management/listuser action.");
        this.users = LoginInfo.listAll();
        this.roles = Role.listAll();
        return SUCCESS;
    }
}
